package provider;

import anaydis.sort.Sorter;
import anaydis.sort.SorterType;
import anaydis.sort.provider.SorterProvider;
import impl.*;
import org.jetbrains.annotations.NotNull;

import java.util.EnumMap;
import java.util.Map;

public class SorterProviderImpl implements SorterProvider {

    private Map<SorterType, Sorter> map;

    public SorterProviderImpl() {
        map = new EnumMap<SorterType, Sorter>(SorterType.class);
        map.put(SorterType.BUBBLE, new BubbleSorter());
        map.put(SorterType.INSERTION, new InsertionSorter());
        map.put(SorterType.SELECTION, new SelectionSorter());
        map.put(SorterType.QUICK,new QuickSorter());
        map.put(SorterType.SHELL,new ShellSort());
        map.put(SorterType.MERGE,new MergeSorter());
        map.put(SorterType.MERGE_BOTTOM_UP,new MergeBottUpSorter());
        map.put(SorterType.QUICK_NON_RECURSIVE,new QuickSortNonRecursive());
        map.put(SorterType.QUICK_CUT,new QuickSortWithCut());
        map.put(SorterType.QUICK_THREE_PARTITION,new QuickSortThreeWayPartition());
        map.put(SorterType.HEAP,new HeapSorter());
        map.put(SorterType.HEAP_TERNARY,new HeapOrderedSorter());

    }

    public Sorter getSorterForType(SorterType sorterType) {
        return map.get(sorterType);
    }

    public Iterable<Sorter> getAllSorters() {
        return map.values();
    }
}
